package vsvm.data.model;

import java.util.HashMap;

import vsvm.gui.Environment;

public class CategorialAttribute extends AbstractAttribute {
	private static final long serialVersionUID = 100L;
	
	private HashMap<String, Double> map;
	private double current;

	public CategorialAttribute(String name) {
		this.name = name;
		current = 1;
		map = new HashMap<String, Double>();
	}
		
	@Override
	public int getAttributeType() {
		return AbstractAttribute.CATEGORIAL_TYPE;
	}
	
	public double toDouble(String str) {
		if (!map.containsKey(str)) {
			map.put(str, new Double(current));
			current += 1;
		}
		
		return map.get(str).doubleValue();
	}
	
	public String getQuickInfo() {
		return "Categorial attribute" + Environment.newline + "Categories: " + map.size();
	}

}
